#不断求余和乘以10，注意溢出
class Solution:
    def reverse(self, x):
        """
        :type x: int
        :rtype: int
        """
        
        if x < 0:
            return -self.reverse(-x)
        
        n = x
        tmp = 0
        while n:
            tmp = tmp*10 + n%10
            n = int(n/10)
        return tmp if abs(tmp)< 2147483648 else 0
 
                
        